package com.tiancheng.trade.authserver.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Date;

@TableName("auth_user")
@Getter
@Setter
@Accessors(chain = true)
public class AuthUser extends BaseModel {
    private String name;
    private String email;
    private String password;
    /**
     * 密码修改日期,时间戳,单位秒
     */
    private Long passwordModifiedDate;
    /**
     * 密码有效天数
     */
    private Integer passwordValidDays;
    private String phone;
    /**
     * 状态<br/>
     * 0:正常, <br/>
     * 1:禁用,<br/>
     */
    private Integer status;

    /**
     * 是否是游客账户,游客账户代表oauth2首次登陆用户,未关联过系统需要的信息,如邮箱或者电话号码
     */
    private Boolean isTourist = false;
    /**
     * 注册时间
     */
    private Date signUpDate;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof AuthUser)) {
            return false;
        }
        AuthUser authUser = (AuthUser) o;
        if (this.getId() != null && this.getId().equals(authUser.getId())) {
            return true;
        } else if (this.getEmail() != null && this.getEmail().equals(authUser.getEmail())) {
            return true;
        } else {
            return this.getPhone() != null && this.getPhone().equals(authUser.getPhone());
        }
    }

    public String getStatusName() {
        if (this.status == 0) {
            return "正常";
        } else {
            return "禁用";
        }
    }
}
